<template>
  <div class="login-box">
    <el-form label-width="60px">
      <el-form-item label="用户名">
        <el-input v-model="user.username"></el-input>
      </el-form-item>
      <el-form-item label="用户名">
        <el-input v-model="user.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="btnLoginClick">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      user: {
        username: '',
        password: ''
      }
    }
  }, methods: {
    btnLoginClick() {
      this.axios({
        url: 'http://localhost:8080/user/login',
        method: 'post',
        params: this.user,
        dataType: 'json'
      }).then((res) => {
        if (res.data.success) {
          this.$router.push('/list');
        }
      })
    }
  }
}
</script>

<style scoped>

.login-box {
  width: 500px;
  margin-top: 400px;
  margin-left: 500px;
}

</style>